package cn.itcast.nems.studentrecord.service.impl.studentrecord;

import cn.itcast.nems.studentrecord.dao.entity.StudentRecordStudentRelationship;
import cn.itcast.nems.studentrecord.dao.mapper.StudentRecordStudentRelationshipMapper;
import cn.itcast.nems.studentrecord.service.studentrecord.StudentRecordStudentRelationshipService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
@Slf4j
public class StudentRecordStudentRelationshipServiceImpl implements StudentRecordStudentRelationshipService {
    private final StudentRecordStudentRelationshipMapper studentRecordStudentRelationshipMapper ;

    public List<StudentRecordStudentRelationship> findByStudentRecordId(String recordId) {
        return  studentRecordStudentRelationshipMapper.selectList(new LambdaQueryWrapper<StudentRecordStudentRelationship>()
                .eq(StudentRecordStudentRelationship::getStudentRecordId,recordId)
                .orderByDesc(StudentRecordStudentRelationship::getCreatedDatetime)) ;
    }

    @Override
    public Integer findStudentId(String studentRecordId){
        return this.studentRecordStudentRelationshipMapper.selectStudentId(studentRecordId);
    }
}
